package com.fotile.weixin.event.dto;

import com.fotile.base.SpringContextHolder;
import com.fotile.weixin.event.dto.enums.RequestType;
import com.fotile.weixin.event.processor.*;


/**
 * 指令匹配器
 */
public class InstructionMatcher {
    public static Processor<InstructionObject> match(InstructionObject io) {
        RequestDTO request = io.getRequest();

//                视频消息

//                链接消息
        switch (RequestType.getByValue(request.getMsgType())) {
            case EVENT:
                return SpringContextHolder.getBean(EventProcessor.class);
//            文本消息
            case TEXT:
                return SpringContextHolder.getBean(TextProcessor.class);
//            语音消息
            case VOICE:
                return SpringContextHolder.getBean(VoiceProcessor.class);
//            图片消息
            case IMAGE:
                return SpringContextHolder.getBean(PictureProcessor.class);
//            位置消息
            case LOCATION:
                return SpringContextHolder.getBean(LocationProcessor.class);
            default:
                return SpringContextHolder.getBean(UnknowRequestTypeProcessor.class);
        }
    }
}
